package com.example.spring_ioc.Controller;

import com.example.spring_ioc.Service.UserService;
import com.example.spring_ioc.model.UserInfo;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;// 取出对象,声明属性

//    @Autowired // 属性注入
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }

//    public UserController() {
//        System.out.println("无参构造方法");
//    }

//    private UserService userService;// 取出对象,声明属性
//
//    private UserInfo userInfo;
//
//    @Autowired // 构造方法注入
//    public UserController(UserService userService,UserInfo userInfo) {
//        this.userService = userService;
//        this.userInfo = userInfo;
////        System.out.println("有参构造方法");
//    }

//    private UserService userService;// 取出对象,声明属性
//
////     set方法注入
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

    public void say() {
        System.out.println("UserController.say...");
        userService.say();
//        System.out.println(userInfo);
    }
}
